def check(s,weight,M):
    news=s[:17]
    sum=0
    cnt=0
    for i in news:
        if i<'0' or i>'9':
            return False
        else:
            sum+=int(i)*weight[cnt]
            cnt+=1
    sum%=11
    if s[-1]==M[sum]:
        return True
    else:
        return False

weight=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
M=['1','0','X','9','8','7','6','5','4','3','2']

n=int(input())
count=0
for i in range(n):
    s=input()
    if check(s,weight,M)==False:
        print(s)
    else:
        count+=1
if count==n:
    print("All passed")




